package org.webgene.wrapper;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class HTTPGetter {
	public String request(String url) throws Exception {
		
		HttpClient client = new DefaultHttpClient();
		ResponseHandler<String> resHandler = new BasicResponseHandler();
		HttpGet httpGet = new HttpGet();
		try {
			httpGet.setURI(new URI(url));
		} catch (URISyntaxException e) {
			throw new Exception(e);
		}
		
		String reponseBody = "";
		try {
			reponseBody = client.execute(httpGet, resHandler);
		} catch (Exception e) {
			throw new Exception(e);
		}
		return reponseBody;
	}
}
